using System;
using System.Data;
using System.Drawing;
using ReportPrinting;

namespace LanAnh
{
	/// <summary>
	/// DataTable using margins
	/// </summary>
	public class ReportTest8 : IReportMaker
	{
		public void MakeDocument(ReportDocument reportDocument)
        {
            TextStyle.ResetStyles();

            TextStyle.Normal.BackgroundBrush = Brushes.Beige;

            ReportBuilder builder = new ReportBuilder(reportDocument);
            builder.StartLinearLayout(Direction.Vertical);

            builder.AddText("This isn't supposed to be pretty - just testing various, random ReportSectionTable with margins");

            DataView dv = SampleReportMaker1.GetDataView();
            dv.RowFilter = "BirthDate > #1/1/1940#";

            builder.AddTable (dv, true);
            builder.AddAllColumns (2.0f, true, true);
            builder.CurrentSection.MarginLeft = 1.0f;
            builder.CurrentSection.MarginBottom = 0.2f;

            builder.AddSection(new SectionLine(Direction.Horizontal));

            builder.AddTable (dv, true);
            builder.AddAllColumns (2.0f, true, true);
            builder.CurrentSection.HorizontalAlignment = HorizontalAlignment.Center;
            builder.CurrentSection.MarginRight = 1.0f;
            builder.CurrentSection.MarginTop = 0.5f;
            builder.CurrentSection.MarginBottom = 0.2f;

            builder.AddSection(new SectionLine(Direction.Horizontal));

            builder.AddTable (dv, true);
            builder.AddAllColumns (2.0f, true, true);
            builder.CurrentSection.HorizontalAlignment = HorizontalAlignment.Center;

            builder.AddSection(new SectionLine(Direction.Horizontal));

            // Start going horizontally to add two tables side by side
            builder.StartLinearLayout(Direction.Horizontal);
            // Don't use the full height, instead, use just the height required.
            builder.CurrentContainer.UseFullHeight = false;

            builder.AddTable (dv, true);
            builder.AddAllColumns (2.0f, true, true);
            builder.CurrentSection.MarginRight = 0.2f;
            builder.CurrentSection.MarginLeft = 0.2f;
            builder.CurrentSection.MarginTop = 0.2f;
            builder.CurrentSection.MarginBottom = 0.2f;
            builder.CurrentSection.VerticalAlignment = VerticalAlignment.Middle;

            DataView dv1 = SampleReportMaker1.GetDataView();
            dv1.RowFilter = "BirthDate < #1/1/1900#";
            builder.AddTable (dv1, true);
            builder.AddAllColumns (2.0f, true, true);
            builder.CurrentSection.MarginRight = 0.2f;
            builder.CurrentSection.MarginLeft = 0.2f;
            builder.CurrentSection.MarginTop = 0.2f;
            builder.CurrentSection.MarginBottom = 0.2f;

            builder.FinishLinearLayout();
            builder.AddSection(new SectionLine(Direction.Horizontal));

            builder.AddText("As you can see, adding a background brush to normal is an easy way to see exactly where each section is located.");
            builder.CurrentSection.MarginTop = 0.2f;

            builder.FinishLinearLayout();
        }



	}
}
